import axios from 'axios';

export const getPic = () =>{
    return axios.get('http://www.imooc.com/api/home/slider',{
        timeout: 10000
    }).then(res=>{
       if(res.data.code === 0){
           return res.data.slider
       }
    }).catch(err =>{
        if(err){
            console.log(err)    
        }
       return [
           {
               linkUrl: 'https://www.baidu.com',
               picUrl: require('../images/404.png')
           }
       ]
    }).then(data => {
        return new Promise(resolve => {
            setTimeout(()=>{
                resolve(data)
            },1000)
        })
    })
}